<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>作业的驳回</title>
		<link rel="stylesheet" type="text/css" href="../../css/weui.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/base.css"/>
		<style>
			body {
				background-color: rgba(100,100,100,0.6);
			}
			/*.modbox,.modbl,.modbc,.modbr{
			 filter:alpha(opacity=80);
			 -moz-opacity:0.8;
			 width:auto !important;
			 width:100%
			 }*/
			.setCenterDiv {
				position: absolute;
				background-color: #fff;
				margin-bottom: 10px;
				margin-left: 20px;
				border: solid #fff;
				border-radius: 5px;
			}
			.jiangeDiv {
				height: 10px;
			}
			.inputTextareaDiv {
				margin-top: 10px;
			}
			#editNoteSpan {
				color: white;
				font-size: 16px;
			}
			#commitBtn {
				margin-right: 10px;
				color: #0CB800;
				visibility: hidden;
			}
			.tdImgSet img {
				width: 30px;
				height: 30px;
			}
			.dafenDiv {
				margin-top: 10px;
				width: 100%;
				clear: both;
				font-weight: lighter;
				margin-left: 60px;
			}
			#dafenSpan {
				float: left;
				display: block;
				line-height: 40px;
				font-size: 20px;
			}
			table {
				padding-left: 20px;
			}
			td {
			}
			#successA {
				/*position: relative;*/
			}
			#commentTextarea {
				height: 100px;
			}
			#alertDiv {
				display: none;
			}
			#fabiaoBtn {
				margin-top: 20px;
				width: 80%;
			}
			:focus {
				outline: 0;
			}
			* {
				-webkit-tap-highlight-color: rgba(255,255,255,0);
			}
			input, textarea {
				-webkit-appearance: none;
				border-radius: 0;
			}
			.title1 {
				line-height: 1.2em;
				font-size: 18px;
				color: #323232;
				text-align: center;
				padding-left: 10px;
			}
		</style>
	</head>
	<body >
		<div class="showSelectListDiv">
			<div class="setCenterDiv">
				<div class="writeReport ">
					<div class="bgwhite top_2">
						<!--<button type="button" class="  right titlepos1" style="border:none;font-size: 23px ;margin-right: 10px;" onclick="closeFrame()">
						&times;
						</button>-->
						<span class=" mui-icon mui-icon-closeempty right right_15 top_5" onclick="closeFrame()"></span>
						<p class="title1 titlepos">
							驳回原因
						</p>
						<div class="textare_div">
							<textarea class="textarea_t " id="summary"  placeholder="字数最多300字" autofocus="autofocus"></textarea>
						</div>
						<button id="sumbit_bt" type="button" class=" top_10   mui-btn  mui-btn-warning mui-btn-block  " onclick="through()" >
							提交
						</button>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/databaseOperation.js"></script>
	<script type="text/javascript" src="../../script/url.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/utils.js"></script>
	<script type="text/javascript">
		//		var url = 'http://cfnet.org.cn/index2.php?m=android&c=Freecourse&a=adddiscuss';
		var pageParam = '';
		apiready = function() {
			pageParam = api.pageParam;
			ChangeFrame();
			//安卓手机系统返回键事件
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				api.closeFrame({
					name : 'Teach_homework_Addreject'
				});
			});
		}
		function ChangeFrame() {
			$('.showSelectListDiv').css('height', api.frameHeight);
			var textWidth = api.frameWidth - 80;
			$api.css($api.dom('textarea'), 'width:' + textWidth + 'px;');
			var dafenWidth = api.frameWidth - 120;
			$api.css($api.dom('.dafenDiv'), 'width:' + dafenWidth + 'px;');
			// 设置居中
			$api.css($api.dom('.setCenterDiv'), 'top: ' + (api.frameHeight - 219) / 2 + 'px;width: ' + (api.frameWidth - 40) + 'px;');
		}

		// 驳回作业
		function through() {
			var comment = $('#summary').val();
			if (comment == null || comment == "") {
				ShowToast("输入不能为空");
				return;
			} else if (comment.length > 300) {
				ShowToast("字数不能超过300字");
				return;
			}
			var params = {
				jid : $api.getStorage('cfnetppjxid'),
				//				uid:"11924",
				uid : $api.getStorage('cfnetppuid'),
				studyid : pageParam.studyid,
				cid : pageParam.cid,
				vid : pageParam.vid,
				pid : pageParam.pid,
				wid : pageParam.wid,
				comment : comment,
				status : '1',
			};
			showProgress();
			cfnetppPOST(url_teacherwork, params, true, function(data, status) {
				//coding...
				if (data) {
					hideProgress();
					if (data.code == "200") {
						api.toast({
							msg : '上传成功'
						});
						api.sendEvent({
							name : 'Teach_freecourse_homeworks',
							extra : {
								sid : pageParam.studyid,
								type : 1,
								name : pageParam.stuname,
								score : '',
							}
						});
						if (pageParam.pid == 5017) {
							var xjid = $api.getStorage('cfnetppjxid');
							//教学
							var sjid = $api.getStorage('cfnetppjid');
							//实习
							if (xjid == '' || xjid == null || sjid == '' || sjid == null) {
								ApplyAccount();
							}
						} 
							api.closeWin({
								name : 'Teach_freecourse_homeworks'
							});
						
					} else {
						api.closeWin({
							name : 'Teach_freecourse_homeworks'
						});
						var tishi = "数据请求出错！！！";
						if (data.code == "100" || data.code == "109") {
							tishi = "提交失败";
						}
						if (data.code == "101") {
							tishi = "参数错误";
						}
						if (data.code == "106") {
							tishi = "章节未找见";
						}
						if (data.code == "107") {
							tishi = "作业未找见";
						}
						if (data.code == "118") {
							tishi = "作业已经过期";
						}
						if (data.code == "119") {
							tishi = "已经提交过";
						}
						ShowToast(tishi);
					}
				} else {
					ShowToast("提交失败");
				}
			});
		}

		function closeFrame() {
			api.closeFrame({
				name : 'Teach_homework_Addreject'
			});
		}

		function sendNotifi() {
			//			api.sendEvent({
			//				name : 'RefreshAddDiscusListNotifi'
			//			});
		}

		//长风模式体验申请
		function ApplyAccount() {
			var params = {
				jid : 419,
				uid : $api.getStorage('cfnetppuid'),
				pid : pageParam.pid,
				wid : pageParam.wid,
			}
			cfnetppPOST(url_TecGetWorkNum, params, true, function(data, status) {
//				alert(JSON.stringify(data));
				if (data) {
					if (data.code == "200") {
						var datas = data.data;
						if (datas.num > 19 && datas.iscfnt == 0) {
							api.confirm({
								title : '提示',
								msg : '长风模式体验申请',
								buttons : ['确定', '取消']
							}, function(ret, err) {
								var index = ret.buttonIndex;
								if (index == 1) {//确定
				                  api.openWin({useWKWebView:true,
					              name : 'changfengmoshiApply',
					              url : '../changfengmoshiApply.html'});
						           api.closeWin({
										name : 'Teach_freecourse_homeworks'
									});
				             
								} else {//取消
									api.closeWin({
										name : 'Teach_freecourse_homeworks'
									});
								}
							});
						} else {
							api.closeWin({
								name : 'Teach_freecourse_homeworks'
							});
						}
					}
				}
			})
		}
	</script>
</html>
